#include <iosfwd>
#include <iostream>
#include <sstream>
#include <vector>

//
// Created by lingzhitech on 25-9-12.
//

#include <string>
#include <cctype>

// 检查一个号码是否合法
bool valid(const std::string &num) {
    // 必须全部是数字
    for (char c : num) {
        if (!std::isdigit(static_cast<unsigned char>(c)))
            return false;
    }
    // 长度 7～11 位算合法
    return num.size() >= 7 && num.size() <= 11;
}

// 把号码格式化为 xxx-xxxx 或 xxx-xxxx-xxxx 之类
std::string format(const std::string &num) {
    std::string res = num;
    if (num.size() == 7) {
        // 本地号码 7 位 → xxx-xxxx
        res = num.substr(0, 3) + "-" + num.substr(3);
    } else if (num.size() == 10) {
        // 10 位 → xxx-xxx-xxxx
        res = num.substr(0, 3) + "-" + num.substr(3, 3) + "-" + num.substr(6);
    } else if (num.size() == 11) {
        // 11 位 → xxxx-xxxxxxx
        res = num.substr(0, 4) + "-" + num.substr(4);
    }
    // 其它长度保持原样
    return res;
}

struct PersonInfo {
    std::string name;
    std::vector<std::string> phones;
};

int main() {
    std::string line, word; // will hold a line and word from input, respectively
    std::vector<PersonInfo> people; // will hold all the records from the input
    // read the input a line at a time until cin hits end-of-file (or another error)
    while (getline(std::cin, line)) {
        PersonInfo info; // create an object to hold this record's dataistringstream record(line); // bind record to the line we just read
        std::istringstream record(line); // bind record to the line we just read
        record >> info.name; // read the name
        while (record >> word) // read the phone numbers
            info.phones.push_back(word); // and store them
        people.push_back(info); // append this record to people
    }
    for (const auto &entry : people) { // for each entry in people
        std::ostringstream formatted, badNums; // objects created on each loop
        for (const auto &nums : entry.phones) { // for each number
            if (!valid(nums)) {
                badNums << " " << nums; // string in badNums
            } else
                // ''writes'' to formatted's string
                    formatted << " " << format(nums);
        }
        if (badNums.str().empty()) // there were no bad numbers
            std::cout << entry.name << " " // print the name
            << formatted.str() << std::endl; // and reformatted numbers
        else // otherwise, print the name and bad numbers
            std::cerr << "input error: " << entry.name
            << " invalid number(s) " << badNums.str() << std::endl;
    }
}